package com.daoeping.action;

import java.util.ArrayList;
import java.util.List;

import com.daoeping.data.Bzn_questionfavorite;
import com.daoeping.data.Usr_friendgroup;
import com.daoeping.data.Usr_user;
import com.daoeping.domain.JsonData;
import com.daoeping.data.Usr_friend;
import com.daoeping.service.Usr_friendService;
import com.daoeping.service.Usr_friendgroupService;
import com.daoeping.util.ConverntJsonData;
import com.opensymphony.xwork2.ActionContext;

public class Usr_friendgroupAction {
	private Usr_friendgroup usr_friendgroup;
	private Usr_friendgroupService usr_friendgroupService;
	private Usr_friendService usr_friendService;
	private Usr_friend usr_friend;
	private JsonData jsonData;
	
	public Usr_friend getUsr_friend() {
		return usr_friend;
	}

	public void setUsr_friend(Usr_friend usr_friend) {
		this.usr_friend = usr_friend;
	}

	public Usr_friendService getUsr_friendService() {
		return usr_friendService;
	}

	public void setUsr_friendService(Usr_friendService usr_friendService) {
		this.usr_friendService = usr_friendService;
	}

	public JsonData getJsonData() {
		return jsonData;
	}

	public void setJsonData(JsonData jsonData) {
		this.jsonData = jsonData;
	}

	public Usr_friendgroup getUsr_friendgroup() {
		return usr_friendgroup;
	}

	public void setUsr_friendgroup(Usr_friendgroup usr_friendgroup) {
		this.usr_friendgroup = usr_friendgroup;
	}
	
	public Usr_friendgroupService getUsr_friendgroupService() {
		return usr_friendgroupService;
	}

	public void setUsr_friendgroupService(
			Usr_friendgroupService usr_friendgroupService) {
		this.usr_friendgroupService = usr_friendgroupService;
	}

	public String addUsr_friendgroup(){
		if(!usr_friendgroupService.addUsr_friendgroup(usr_friendgroup)){
			return "exception";
		}
		Usr_friend usr_friend = new Usr_friend();
		usr_friend.setUsr_friendgroup(usr_friendgroup);
		usr_friend.setUsr_userByUserId((Usr_user)ActionContext.getContext().getSession().get("user"));
		List<String> list = new ArrayList<String>();
		if(usr_friendService.addUsr_friend(usr_friend)){
			list.add("success");
			jsonData = new JsonData();
			jsonData.setJsonData(new ConverntJsonData().getJsonData(list).toString());
			return "addUsr_friendgroup";
		}else{
			return "exception";
		}
	}
	
	public String findUsr_friendgroupList(){
		if(usr_friend==null){
			usr_friend = new Usr_friend();
		}
		usr_friend.setUsr_userByUserId((Usr_user)ActionContext.getContext().getSession().get("user"));
		jsonData = usr_friendgroupService.findUsr_friendgroupList(usr_friend);
		return "findUsr_friendgroupList";
	}
	
	
}
